import matplotlib.pyplot as plt
import numpy as np
from test3 import create_polar_system

# 创建极坐标系
fig, ax = create_polar_system(r_range=(0, 5))

# 圆心在(-a,0)的圆
theta = np.linspace(0, 2*np.pi, 200)
a = 2
color = 'r'

# 计算ρ值：ρ = -2acos θ
rho_simplified = -2 * a * np.cos(theta)

# 绘制圆
ax.plot(theta, rho_simplified, 'b--', linewidth=2, 
        label=f'ρ = -2acosθ')

# 标记圆心位置 (-a,0) - 在极坐标中对应(θ=π, ρ=a)
ax.plot(np.pi, a, color + 'o', markersize=6)
ax.text(np.pi, a+0.3, f'圆心({-a}, 0)', fontsize=10, color=color, ha='center')


# 添加图例
ax.legend(loc='upper right', bbox_to_anchor=(1.15, 1.15))

# 标记极点
ax.plot(0, 0, 'ko', markersize=6, label='极点')
ax.text(0.1, 0.3, 'O', fontsize=10, color='black')

plt.tight_layout()
plt.show()